package com.ssy.mall;

import com.ssy.mall.common.Constant;
import com.ssy.mall.exception.SsyMallException;
import com.ssy.mall.exception.SsyMallExceptionEnum;

public enum Order {
        CANCELED(0,"用户已取消"),
        NOT_PAID(10,"未付款"),
        PAID(20,"已付款"),
        DELIVERED(30,"已发货"),
        FINISHED(40,"交易完成");

        private int code;
        private String value;


        Order(int code,String value) {
            this.value = value;
            this.code = code;
        }
        public static Order codeof(int code){
            for (Order orderStatusEnum:values()){
                if (orderStatusEnum.getCode() == code){
                    return orderStatusEnum;
                }
            }
            throw new SsyMallException(SsyMallExceptionEnum.NO_ENUM);
        }

        public int getCode() {
            return code;
        }

        public void setCode(int code) {
            this.code = code;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

}
